package com.ss.android.article.base.feature.feed.presenter;

import android.content.Context;
import com.bytedance.article.common.c.TTUtils;
import com.ss.android.article.base.feature.app.a.ArticleConstants;
import com.ss.android.common.AbsApiThread;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.http.legacy.a.NameValueImpl;
import java.util.ArrayList;
import java.util.List;

public final class DislikeActionReportThread extends AbsApiThread {
    private Context context;
    private final long ad_id;
    private final String action;

    public DislikeActionReportThread(Context context, long ad_id, String action) {
        super(Priority.LOW);
        this.context = context != null ? context.getApplicationContext() : null;
        this.ad_id = ad_id;
        this.action = action;
    }

    private static boolean report(Context context, long ad_id, String action) {
        boolean v0 = false;
        if(!android.support.design.a.isTextEmpty(action)) {
            for(int i = 0; i < 2; ++i) {
                try {
                    ArrayList arrayList = new ArrayList();
                    arrayList.add(new NameValueImpl("ad_id", String.valueOf(ad_id)));
                    String adActionDislikeUrlV1 = ArticleConstants.adActionDislikeUrlV1;
                    if("undislike".equals(action)) {
                        adActionDislikeUrlV1 = ArticleConstants.adActionUndislikeUrlV1;
                    }

                    if(android.support.design.a.isTextEmpty(NetworkUtils.executePost(20480, adActionDislikeUrlV1, ((List)arrayList)))) {
                        continue;
                    }
                } catch(Throwable throwable) {
                    int errCode = TTUtils.getErrorCode(context, throwable);
                    errCode = errCode == 13 || errCode == 14 ? 1 : 0;
                    if(errCode == 0) {
                        return v0;
                    }
                 continue;
                }
                return true;
            }
        }
        return v0;
    }

    public final void run() {
        report(this.context, this.ad_id, this.action);
    }
}

